<div id="divAddGroup">
    <?php echo View::factory('admin/common/breadcrumbs')->set('breadcrumbs', $breadcrumbs)->render(); ?>

    <div class="page-content">
        <div class="page-header">
            <h1>
                List Group     
            </h1>
        </div>
        <?php echo View::factory('admin/common/messege')->render(); ?>
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="row-fluid">
                    <div class="span12">
                        <div class="widget-box">
                            <div class="widget-header widget-header-blue widget-header-flat">

                                <p style="padding: 300px;font-size: 21px;">Edit Group Permission <span style="font-weight: bold;color: black"></span></p>

                            </div>

                            <div class="widget-body">
                                <div class="widget-main"><form class="form-horizontal" id="validation-form" method="post" action="<?php echo URL::base() . '/admin/group/edit' ?>">
                                        <div class="step-content row-fluid position-relative" id="step-container">


                                            <?php
                                            if (!empty($a_group)) {
                                                $en_group = $a_group->get_data();
                                                $namegroup = $en_group->getName();
                                                $description = $en_group->getDescription();
                                                $location_id = $en_group->getLocation_Id();
                                            } else {
                                                $namegroup = "";
                                                $description = "";
                                                $location_id = "";
                                            }
                                            ?>
                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" >Name <span class="red">*</span>:</label>

                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">
                                                        <input type="text" id="namegroup" name="namegroup" class="col-xs-12 col-sm-5" value="<?= $namegroup ?>" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="space-2"></div>

                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" >Description <span class="red">*</span>:</label>

                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">
                                                        <input type="text" id="description" name="description" class="col-xs-12 col-sm-5" value="<?= $description ?>" />
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="space-2"></div>
                                            
                                            <div class="space-2"></div>
                                            <div class="control-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="permission">Permission <span class="red">*</span>:</label>
                                            
                                                <div class="controls" style="margin-left: 280px;padding: 10px 0;">
                                                    <select id='permission_id' name="permission_id[]" multiple='multiple'>
                                                        <?php
                                                        if (!empty($a_p_controller[0])) {
                                                            foreach ($a_p_controller as $o_pc) {
                                                                $o_emtity_pc = $o_pc->get_data();
                                                                $s_per = $o_emtity_pc->get_Permission();
                                                                $a_data_per = $s_per->query_all();
                                                                ?>
                                                                <optgroup label='<?= $o_emtity_pc->getDescription() ?>'>
                                                                    <?php
                                                                    if (!empty($a_data_per[0])) {
                                                                        foreach ($a_data_per as $o_data_per) {
                                                                            $o_entity_per = $o_data_per->get_data();
                                                                            $selected = "";
                                                                            if (!empty($a_permission_id) && is_array($a_permission_id) && in_array($o_entity_per->getId(), $a_permission_id)) {
                                                                                $selected = "selected";
                                                                            }
                                                                            echo "<option $selected value='" . $o_entity_per->getId() . "'>" . $o_entity_per->getDescription() . "</option>";
                                                                        }
                                                                    }
                                                                    ?>
                                                                </optgroup>
                                                                <?php }
                                                            }
                                                            ?>
                                                    </select>
                                                </div>
                                                <div class="controls" style="margin-left: 272px;padding: 10px 0;">
                                                        <?= Form::input('selectall', 'Select All', array('type' => 'button', 'id' => 'selectallper', 'class' => 'btn tip-bottom')) ?>
<?= Form::input('deselectall', 'Deselect All', array('type' => 'button', 'id' => 'deselectallper', 'class' => 'btn tip-bottom')) ?>
                                                </div>
                                            </div>
                                            <div class="space-8"></div>              

                                        </div>
                                        <hr />

                                        <div class="row-fluid wizard-actions">
<?= Form::input('cmdCancel', 'Cancel', array('class' => 'btn btn-prev', 'type' => 'button', 'onclick' => 'window.location= "' . URL::base() . 'admin/group/list"')) ?>
<?= Form::submit('cmdEdit', '  Save  ', array('class' => 'btn btn-success btn-next')) ?>

                                            <!--                                        <button id="cmdCancelAddGroup" class="btn btn-prev">
                                                                                        <i class="icon-arrow-left"></i>
                                                                                        Cancel
                                                                                    </button>
                                            
                                                                                    <button id="cmdeditgroup" class="btn btn-success btn-next" data-last="Finish ">
                                                                                        Submit
                                                                                        <i class="icon-arrow-right icon-on-right"></i>
                                                                                    </button>
                                                                                    <img id="loading" style="display: none;" src="<?= $url_base_theme . '/img/loading_1.gif' ?>" />-->
                                        </div>
                                    </form>
                                </div><!-- /widget-main -->
                            </div><!-- /widget-body -->
                        </div>
                    </div>
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->

    </div>
</div>

<script>
    var _group_edit = group_edit.CreateObject({
        id: '_group_edit',
        full_url: '<?= Controller_Helper_Url::full_url() ?>',
        id_group: '<?= $_GET['id']; ?>'
    });
</script>
